home *** CD-ROM | disk | FTP | other *** search
/ PC Graphics Unleashed / PC Graphics Unleashed.iso / ch01 / genoa.asm < prev    next >
Assembly Source File  |  1991-06-22  |  6KB  |  213 lines

  1. ; This is file c:\djgpp\drivers\genoa.asm
  2. ;
  3. ; Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  4. ;
  5. ; This file is distributed under the terms listed in the document
  6. ; "copying.dj", available from DJ Delorie at the address above.
  7. ; A copy of "copying.dj" should accompany this file; if not, a copy
  8. ; should be available from where this file was obtained.  This file
  9. ; may not be distributed without a verbatim copy of "copying.dj".
  10. ;
  11. ; This file is distributed WITHOUT ANY WARRANTY; without even the implied
  12. ; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. ;
  14.  
  15. ; Adaption to Genoa Series 6000 SVGA by D. Wilmer 04-Jun-1991
  16.  
  17. cseg    segment byte public 'code'
  18.         assume  cs:cseg, ds:cseg, es:cseg, ss:nothing
  19.  
  20.         dw      offset init_routine
  21.         dw      offset paging_routine
  22.         dw      1       ; set to 1 if separate read & write windows or
  23.                         ; only 64K of video RAM (ie: no paging)
  24.  
  25. def_tw  dw      80      ; filled in by go32 if GO32 env. var. is set
  26. def_th  dw      25
  27. def_gw  dw      640
  28. def_gh  dw      480
  29.  
  30. ;--------------------------------------------------------------------------
  31. ; Entry: AX=mode selection
  32. ;               0=80x25 text
  33. ;               1=default text
  34. ;               2=text CX cols by DX rows
  35. ;               3=biggest text
  36. ;               4=320x200 graphics
  37. ;               5=default graphics
  38. ;               6=graphics CX width by DX height
  39. ;               7=biggest non-interlaced graphics
  40. ;               8=biggest graphics
  41. ;
  42. ; NOTE: This runs in real mode, but don't mess with the segment registers.
  43. ;
  44. ; Exit:  CX=width (in pixels or characters)
  45. ;        DX=height
  46.  
  47. init_table      label   word
  48.         dw      offset init_0
  49.         dw      offset init_1
  50.         dw      offset init_2
  51.         dw      offset init_3
  52.         dw      offset init_4
  53.         dw      offset init_5
  54.         dw      offset init_6
  55.         dw      offset init_7
  56.         dw      offset init_8
  57.  
  58. init_routine    proc    far
  59.         cmp     ax,8
  60.         jbe     valid_req
  61.         ret
  62. valid_req:
  63.         shl     ax,1
  64.         mov     bx,ax
  65.         jmp     init_table[bx]
  66.  
  67. init_0: ; 80x25 text
  68.         mov     ax,3
  69.         int     10h
  70.         mov     cx,80
  71.         mov     dx,25
  72.         ret
  73.  
  74. init_1: ; default text
  75.         mov    cx,def_tw
  76.         mov     dx,def_th
  77.         jmp     init_2
  78.  
  79. init_2_table    label   word
  80.         dw      01h, 40, 25
  81.         dw      03h, 80, 25
  82.         dw      60h, 132, 25
  83.         dw      61h, 132, 29
  84.         dw      62h, 132, 32
  85.         dw      63h, 132, 44
  86.         dw      64h, 132, 60
  87. init_2_tend     label   word
  88.  
  89. init_2: ; CX*DX text
  90.         mov     si,offset init_2_table
  91. init_2a:
  92.         cmp     [si+2],cx
  93.         jb      init_2b
  94.         cmp     [si+4],dx
  95.         jb      init_2b
  96.         ; got a big enough one!
  97.         jmp     init_2c
  98. init_2b:
  99.         cmp     si,offset init_2_tend - 6
  100.         je      init_2c
  101.         add     si,6
  102.         jmp     init_2a
  103. init_2c:
  104.         mov     ax,[si]
  105.         push    si
  106.         int     10h
  107.         pop     si
  108.         mov     cx,[si+2]
  109.         mov     dx,[si+4]
  110.         ret
  111.  
  112. init_3: ; biggest text
  113.         mov     ax,[init_2_tend-6]
  114.         int     10h
  115.         mov     cx,[init_2_tend-4]
  116.         mov     dx,[init_2_tend-2]
  117.         ret
  118.  
  119. init_4: ; 320x200 graphics
  120.         mov     ax,13h
  121.         int     10h
  122.         mov     cx,320
  123.         mov     dx,200
  124.         ret
  125.  
  126. init_5: ; default graphics - should be 640x480 if supported
  127.         mov     cx,def_gw
  128.         mov     dx,def_gh
  129.         jmp     init_6
  130.  
  131. init_6_table    label   word
  132.         dw      13h, 320, 200
  133.         dw      5Ch, 640, 480
  134.         dw      6Ch, 800, 600
  135. init_6_tend     label   word
  136.  
  137. init_6: ; CX*DX graphics
  138.         mov     si,offset init_6_table
  139. init_6a:
  140.         cmp     [si+2],cx
  141.         jb      init_6b
  142.         cmp     [si+4],dx
  143.         jb      init_6b
  144.         ; got a big enough one!
  145.         jmp     init_6c
  146. init_6b:
  147.         cmp     si,offset init_6_tend - 6
  148.         je      init_6c
  149.         add     si,6
  150.         jmp     init_6a
  151. init_6c:
  152.         mov     ax,[si]
  153.         push    si
  154.         int     10h
  155.         pop     si
  156.         mov     cx,[si+2]
  157.         mov     dx,[si+4]
  158.         ret
  159.  
  160. init_7: ; biggest non-interlaced graphics
  161.         mov     ax,6Ch
  162.         int     10h
  163.         mov     cx,800
  164.         mov     dx,600
  165.         ret
  166.  
  167. init_8: ; biggest graphics
  168.         mov     ax,6Ch
  169.         int     10h
  170.         mov     cx,800
  171.         mov     dx,600
  172.         ret
  173.  
  174. init_routine    endp
  175.  
  176. ;--------------------------------------------------------------------------
  177. ; Entry: AH=read page
  178. ;        AL=write page
  179. ;
  180. ; NOTE: This runs in protected mode!  Don't mess with the segment registers!
  181. ; This code must be relocatable and may not reference any data!
  182. ;
  183. ; Exit: VGA configured.
  184. ;       AX,BX,CX,DX,SI,DI may be trashed
  185.  
  186.         assume  ds:nothing, es:nothing
  187.  
  188. ; 24-May-1991 D. Wilmer
  189. ; Genoa 6000 series bank switching:
  190. ; issue the following byte  x1wwwrrr (binary)
  191. ; with      x: Don't care
  192. ;           1: Don't change
  193. ;           w: 3-bit write segment
  194. ;           r: 3-bit read segment
  195. ;
  196. ; to the port 3c5.06 (memory select register)
  197.  
  198. paging_routine  proc    far
  199.         .386
  200.         shl     al,3
  201.         or      ah,al
  202.         or      ah,40h
  203.         mov     al,6
  204.         mov     dx,3C4h
  205.         out     dx,ax
  206.         ret
  207. paging_routine  endp
  208.  
  209. ;--------------------------------------------------------------------------
  210.  
  211. cseg    ends
  212.         end
  213.